package com.gehj.androidlibs.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.gehj.androidlibs.R;

import org.jetbrains.annotations.NotNull;
/**
 * viewpager的转场动画
 * @author gehj
 * @date 2021/1/9 16:12
 */


public class SplashFragment extends Fragment {

    private ImageView mIvContent;
    private int mResId;
    private static final String BUNDLE_KEY_Res_Id = "key_res_id";

   public static SplashFragment newInstant(int resId){
        Bundle bundle = new Bundle();
        bundle.putInt(BUNDLE_KEY_Res_Id,resId);
        SplashFragment splashFragment = new SplashFragment();
        splashFragment.setArguments(bundle);
       return splashFragment;
   }

    @Override
    public void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            mResId = bundle.getInt(BUNDLE_KEY_Res_Id,0);
        }
    }

    @Nullable
    @org.jetbrains.annotations.Nullable
    @Override
    public View onCreateView(@NonNull @NotNull LayoutInflater inflater, @Nullable @org.jetbrains.annotations.Nullable ViewGroup container, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_splash,container,false);
    }


    /**
     * findviewById 找子控件
     * @param view
     * @param savedInstanceState
     */
    @Override
    public void onViewCreated(@NonNull @NotNull View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        mIvContent = view.findViewById(R.id.iv_content);
        mIvContent.setImageResource(mResId);
        mIvContent.setTag(mResId);
    }
}
